<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@page import="com.domain.ZhongLei,java.util.ArrayList,com.domain.*"%>

<%
YongHu yonghu=(YongHu)session.getAttribute("yonghu");

ZhongLei dangqianzhonglei=(ZhongLei)session.getAttribute("dangqianzhonglei");	

ArrayList<ZhongLei> quanbuzhonglei=(ArrayList<ZhongLei>)session.getAttribute("quanbuzhonglei");
ZhongLei zhonglei;

ArrayList<ShangPin> fenleishangpin=(ArrayList<ShangPin>)session.getAttribute("fenleishangpin");
ShangPin shangpin;

if(yonghu==null)
{
	request.getRequestDispatcher("yonghudenglu.jsp").forward(request, response);

}

if(dangqianzhonglei==null || fenleishangpin==null)
{
	request.getRequestDispatcher("Shangchengshouye").forward(request, response);
}
%>

<html>
  <head>
	  <style>A{text-decoration: NONE} </style>
	  <title>分类商品</title>
  </head>
  <body bgcolor="#d0eed8">

	<table width="100%" >
		<tr>
			<td align="left"><a href="shangchengshouye.jsp">商城首页</a></td>
			<td align="right"><a href="Gerenzhongxin"><%=yonghu.getYonghuming()%></a>&nbsp;<a href="Tuichu">退出</a></td>
		</tr>
	</table>

	<form action="Jiazaifenlei" method="post">
		选择分类
		<select name="zhongleibianhao">
 <%
		for(int i=0;i<quanbuzhonglei.size();i++)
		{
			 zhonglei=quanbuzhonglei.get(i);
			 if(zhonglei.getBianhao().equals(dangqianzhonglei.getBianhao()))
			 {
%>
				<option value=<%=zhonglei.getBianhao() %> selected><%=zhonglei.getMingzi() %></option>
<%					 
			 }
			 else
			 {
%>
				<option value=<%=zhonglei.getBianhao() %>><%=zhonglei.getMingzi() %></option>
<%				 
			 }
		}
%>
		</select>
		<input name="submit1" value="确定" type="submit" />			
	</form>

  	<p align="center"><font size="+5"><%=dangqianzhonglei.getMingzi() %></font>	

	<table align="center" width="100%" cellspacing="10" >
<%
		int i;
		for(i=0;i<fenleishangpin.size();i=i+5)
		{
%>
			<tr align="center" valign="top">
<%			
			for(int j=0;j<5 && i+j<fenleishangpin.size();j++)
			{
				shangpin=fenleishangpin.get(i+j);
%>
				<th width="20%"  colspan="2"><a href="Shangpinxiangqing?shangpinbianhao=<%=shangpin.getBianhao()%>"><%=shangpin.getMingzi() %></a></th>		
<%	
			}
%>
			</tr>
			
			<tr align="center">
<%			
			for(int j=0;j<5 && i+j<fenleishangpin.size();j++)
			{
				shangpin=fenleishangpin.get(i+j);				
%>			
				<td  colspan="2">
					<a href="Shangpinxiangqing?shangpinbianhao=<%=shangpin.getBianhao()%>">
						<img src="./images/<%=shangpin.getTupian().get(0) %>.jpg" width="100%">
					</a>
				</td>		
<%	
			}			
%>
			</tr>

			<tr align="center">
<%		


			for(int j=0;j<5 && i+j<fenleishangpin.size();j++)
			{
				shangpin=fenleishangpin.get(i+j);				
%>			
				<td >¥ <%=shangpin.getJiage() %></td>
				<td >剩余<%=shangpin.getShuliang() %>件</td>	
<%	
			}			
%>
			</tr>

			<tr align="center" valign="top">
<%		
			for(int j=0;j<5 && i+j<fenleishangpin.size();j++)
			{
				shangpin=fenleishangpin.get(i+j);				
%>			
				<td  colspan="2">
					<a href="Shangpinxiangqing?shangpinbianhao=<%=shangpin.getBianhao()%>"><%=shangpin.getMiaoshu() %></a>
				</td>	
<%	
			}	
%>
			</tr>				
<%
		}
%>	
	</table>	
  </body>
</html>
